# encoding: utf-8
'''
Created on 2018-6-13
desription:数据库连接助手类
@author: zhujianhua
'''

import cx_Oracle
import sys

sys.path.append('./helper')
import InfoMonConstants

class ConnectionHelper:
    conn = None
    def __init__(self,dbName):
        tns=cx_Oracle.makedsn(InfoMonConstants.HOST,InfoMonConstants.PORT,dbName)
        self.conn=cx_Oracle.connect(InfoMonConstants.USER,InfoMonConstants.PASSWORD,tns)
        
    def getConnection(self):
        return self.conn
    
    def getCursor(self):
        return self.conn.cursor()

    def execute(self,sql):
        cursor = self.conn.cursor()
        cursor.execute(sql)
        return cursor.fetchall()

